package com.jxm.validation;

import com.jxm.annotation.Mobile;


import com.jxm.utils.RegexUtil;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;


public class MobileValidator implements ConstraintValidator<Mobile, String> {


    @Override
    public void initialize(Mobile constraintAnnotation) {
        ConstraintValidator.super.initialize(constraintAnnotation);
    }

    @Override
    public boolean isValid(String text, ConstraintValidatorContext constraintValidatorContext) {
        if(text == null || text == "" || text.trim().length() <= 0){
            return false;
        }
        return RegexUtil.isMobile(text);
    }
}
